package com.fjzn.detect.service.user.impl;

import com.fjzn.detect.repository.user.entity.SysMenu;
import com.fjzn.detect.repository.user.entity.SysUser;
import com.fjzn.detect.repository.user.mapper.SysMenuMapper;
import com.fjzn.detect.service.user.ISysMenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * <p>
 * 菜单权限表 服务实现类
 * </p>
 *
 * @author hellowrold
 * @since 2021-04-26
 */
@Service
public class ISysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService {

    @Override
    public Set<String> getMenuPermission(SysUser user) {
        Set<String> pers = new HashSet<>();
        if(user.isAdmin()){
            pers.add("*.*.*");
        }else{
            Set<String> permissions = this.baseMapper.getMenuPermission(user.getUserId());
            pers.addAll(permissions);
        }
        return pers;
    }
}
